<?php
/**用户业务枚举**/
class SEnum
{
    const Value = 0;
    const Caption = 1;
    const Remark = 2;
    const Alternate = 3;

    public $EnumTypes = array();
    //通过值获取内容
    function show($v){
        $CurCaption = "";
        foreach($this->EnumTypes as $temp){
            if($temp[self::Value] == $v){
                $CurCaption = $temp[self::Caption];
                break;
            }
        }
        return $CurCaption;
    }

    function showByIndex($v,$index){
        $CurCaption = "";
        foreach($this->EnumTypes as $temp){
            if($temp[self::Value] == $v){
                $CurCaption = $temp[$index];
                break;
            }
        }
        return $CurCaption;
    }

    function getAll(){
        return $this->EnumTypes;
    }
    
    function getAllOneD(){
        $new_array=array();
        foreach($this->EnumTypes as $k=>$v){
            $new_array[]=$v[self::Caption];
        }
        return $new_array;
    }

}

class Demo extends SEnum
{
    Const Frist = array("1",'首次公开');
    Const Two = array("2",'再次公开');
    Const Three = array("3",'取消公开');
    function __construct(){
        $this->EnumTypes = array(self::Frist,self::Two,self::Three);
    }
}
